package cn.xbtop.queue;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jms.core.JmsTemplate;

import javax.jms.JMSException;
import javax.jms.TextMessage;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/6/10 16:04
 */
public class TestQueueConsumer {
    public static void main(String[] args) throws JMSException {
        ApplicationContext ap = new ClassPathXmlApplicationContext("application-queue.xml");
        //((ClassPathXmlApplicationContext) ap).start();

        JmsTemplate jmsTemplate = ap.getBean(JmsTemplate.class);

        //如果不设置目的地，默认监听的是 默认的目的地
        TextMessage textMessage = (TextMessage) jmsTemplate.receive();

        System.out.println(textMessage.getText());
        System.out.println("消息消费成功---");
    }
}
